<!DOCTYPE html>
<html>
<head>
<head />
<div th:include="base-libs :: base-libs" />
<title>医联体详情</title>
</head>
<script th:inline="javascript">
	/**发起机构信息*/
	var fqyljgxx = [[${fqyljgxx}]];
	/**签约申请医联体信息*/
	var qysqxx = [[${qysqxx}]];
	/**签约机构信息*/
	var qyjgxx = [[${qyjgxx}]];
</script>
<script type="text/javascript">
	$(function() {
		initView();
		initData(); 
	});

	function initData() {
		/**加载发起机构信息*/
		initFqjg();
		/**加载医联体信息*/
		initQysqxx();
		/**加载签约机构信息*/
		initQyjgxx();
	}

	function initView() {
		$("#ksTr").find(".ksxx").hide();
		$("#ksTr").find(".yydz").attr("colspan","5");
		$("#jgxxTable").datagrid(getOption());
	}

	/**返回按钮*/
	function btnBackHandler() {
		$.QuickUrlUtils.redirectUrl("index.html");
	}
	
	/**加载发起机构信息*/
	function initFqjg(){
		var jgxx = fqyljgxx;
		$(".fqjg").find("span").each(function(){
			$(this).text(jgxx[$(this).attr("id")]);
		});
	}
	
	/**加载医联体信息*/
	function initQysqxx(){
		if(qysqxx){
			var info;
			$(qyjgxx).each(function(index,item){
				if(item["JGLX"]=="3"){
					info = item;
				}
			});
			info = $.extend({}, info, qysqxx);
			$(".yltxx").find(".dataField").each(function(){
				$(this).text(info[$(this).attr("id")]);
			});
			$("#KSMC").text(qysqxx["KSMC"]).attr("title",qysqxx["KSMC"]);
			$("#BZSM").text(qysqxx["BZSM"]);
			if(qysqxx["YLTLX"]=="03"){
				$("#ksTr").find(".ksxx").show();
				$("#ksTr").find(".yydz").removeAttr("colspan");
				$("#ksTr").find(".kstd").attr("colspan","3");
			}else{
				$("#ksTr").find(".ksxx").hide();
				$("#ksTr").find(".kstd").removeAttr("colspan");
				$("#ksTr").find(".yydz").attr("colspan","5");
			}
		}
	}
	
	/**加载签约机构信息*/
	function initQyjgxx(){
		var removeUpdateBtn = true;
		if(qyjgxx){
			if(qysqxx["YLTLX"] == "03"){
				$("#jgxxTable").datagrid(getOption(qysqxx["YLTLX"]));
			}
			$(qyjgxx).each(function(index, item){
				if(item["JGLX"]=="3"){
					qyjgxx.splice(index,1);
					item["QYZTMC"] = "主导机构";
					qyjgxx.splice(0,0,item);
				}
				if(item.QYZT=='01'){
					removeUpdateBtn = false;
					$("#updateBtn").data("YLTID",item.YLTID);
				}
			});
			var length = 37*(qyjgxx.length);
			$("#maxDiv").css("height",length+620 +"px");
			$("#maxLayout").layout("resize");
			$("#jgxxBody").css("height", length + 43+"px");
			$("#jgxxTable").datagrid("loadData",{"total": qyjgxx.length, "rows": qyjgxx});
		}
		if(removeUpdateBtn){
			$("#updateBtn").remove();
		}
	}
	
	/**获取option*/
	function getOption(lx){
		var opt;
		if(lx == "03"){
			opt= {
					idField : "YLJGDM",
					uniqueId: "PTJGID",
					striped : true,
					border:false,
					clickToSelect: true,
					fit: true,
					fitColumns: true,
					singleSelect: false,
					rownumbers: true,
					columns : [[
						{
							field : "YLJGMC",
							width: 160,
							align: "center",
							title : "机构名称"
						},
						{
							field : "XZQHMC",
							width: 100,
							align: "center",
							title : "所属区域"
						},
						{
							field : "WSJGLBMC",
							width: 120,
							align: "center",
							title : "机构类型"
						},
						{
							field : "KSMC",
							width: 300,
							align: "center",
							title : "科室",
							formatter : function(value, row, index){
								return "<span title='"+value+"'>"+value+"</span>";
							}
						},
						{
							field : "YYDJMC",
							width: 100,
							align: "center",
							title : "医院等级"
						},
						{
							field : "JGFLGLMC",
							width: 120,
							align: "center",
							title : "经营性质"
						},{

							field : "QYZTMC",
							width: 120,
							align: "center",
							title : "签约状态"
						}
					]],onLoadSuccess: function(data){
						$("#jgxxLayout").layout("resize");
					}
				};
		}
		else{
			opt= {
					idField : "YLJGDM",
					uniqueId: "PTJGID",
					striped : true,
					border:false,
					clickToSelect: true,
					fit: true,
					fitColumns: true,
					singleSelect: false,
					rownumbers: true,
					columns : [[
						{
							field : "YLJGMC",
							width: 250,
							align: "center",
							title : "机构名称"
						},
						{
							field : "XZQHMC",
							width: 150,
							align: "center",
							title : "所属区域"
						},
						{
							field : "WSJGLBMC",
							width: 150,
							align: "center",
							title : "机构类型"
						},
						{
							field : "YYDJMC",
							width: 150,
							align: "center",
							title : "医院等级"
						},
						{
							field : "JGFLGLMC",
							width: 150,
							align: "center",
							title : "经营性质"
						},{

							field : "QYZTMC",
							width: 120,
							align: "center",
							title : "签约状态"
						}
					]],onLoadSuccess: function(data){
						console.log(data);
						$("#jgxxLayout").layout("resize");
					}
				};
		}
		return opt;
	}
	
	/** 修改医联体  */
	function toManager(){
		var YLTID = $("#updateBtn").data("YLTID");
		$.QuickUrlUtils.redirectUrl("manager.html?YLTID=" + YLTID);
	}
</script>

<body class="easyui-layout">
	<div region="center">
		<div id="maxDiv" style="height: 850px;" >
			<div id="maxLayout" class="easyui-layout" >
				<div region="north" style="border: none; overflow: hidden;">
					<h4 class="h4-title" style="font-size: 18px;">
						医联体详情
					</h4>
					<div class="form-table-box" >
						<form id="managerForm" class="form-horizontal" >
							<h4 class="h4-title" style="font-size: 13px;">
								主导机构
							</h4>
							<table class="form-table fqjg">
								<tr>
									<td class="td-text">机构名称：</td>
									<td class="td-content">
										<span id="YLJGMC"></span>
									</td>
									<td class="td-text">机构编码：</td>
									<td class="td-content">
										<span id="YLJGDM"></span>
									</td>
									<td class="td-text">所属区域：</td>
									<td class="td-content">
										<span id="XZQHMC"></span>
									</td>
								</tr>
								
								<tr>
									<td class="td-text">机构类型：</td>
									<td class="td-content">
										<span id="WSJGLBMC"></span>
									</td>
									<td class="td-text">经营性质：</td>
									<td class="td-content">
										<span id="JGFLGLMC"></span>
									</td>
									<td class="td-text">医院等级：</td>
									<td class="td-content">
										<span id="YYDJMC"></span>
									</td>
								</tr>
								<tr id="ksTr">
									<td class="td-text">医院地址：</td>
									<td class="td-content yydz" colspan="5">
										<span id="DWDZ"></span>
									</td>
									<td class="td-text ksxx">科室名称：</td>
									<td class="td-content ksxx kstd" >
										<span id="KSMC" style="white-space:nowrap;"></span>
									</td>
								</tr>
							</table>
							<h4 class="h4-title" style="font-size: 13px;">
								医联体信息
							</h4>
							<table class="form-table yltxx">
								<tr>
									<td class="td-text">医联体名称：</td>
									<td class="td-content">
										<span id="YLTMC" class="dataField"></span>
									</td>
									<td class="td-text">医联体类型：</td>
									<td class="td-content">
										<span id="YLTLXMC" class="dataField"></span>
									</td>
									<td class="td-text">主导医疗机构：</td>
									<td class="td-content">
										<span id="ZDYLJGMC" class="dataField"></span>
									</td>
								</tr>
								<tr>
									<td class="td-text">签约有效期：</td>
									<td class="td-content">
										<span id="QYYXQMC" class="dataField"></span>
									</td>
									<td class="td-text">签约时间：</td>
									<td class="td-content">
										<span id="QYSJ" class="dataField"></span>
									</td>
									<td class="td-text">至</td>
									<td class="td-content">
										<span id="DQSJ" class="dataField">
										</span>
									</td>
								</tr>
							</table>
						</form>
					</div>
				</div>
				<div region="center" style="border: 0;overflow: hidden;">
					<h4 class="h4-title" style="font-size: 13px;">
						添加机构
					</h4>
					<div  id="jgxxBody" style="height:120px;width:96.5%;margin-left:2.5%;">
						<div  id="jgxxLayout" class="easyui-layout" fit="true">
							<div region="center" style="border: none;">
								<table id="jgxxTable" >
											</table>
							</div>
						</div>
					</div>
					<div style="height: 320px;">
						<div class="easyui-layout" fit="true">
							<div region="center" style="border: none; overflow: hidden;">
								<div class="form-table-box" >
									<table class="form-table">
										<tr>
											<td class="td-text">备注说明：</td>
											<td class="td-content" colspan="5">
												<span id="BZSM"></span>
											</td>
										</tr>
									</table>
									<div class="form-table-box" >
										<h4 class="h4-title" style="font-size: 13px;">
											服务协议信息
										</h4>
										<table class="form-table">
											<tr>
												<td class="td-content">
													<input class="easyui-textbox" readonly="readonly" data-options="multiline:true" style="width:100%;height:100px">
												</td>
											</tr>
										</table>
									</div>
									<!-- <div style="text-align: center;padding-bottom:10px;">
										<button class="btn btn-default" type="button" onclick="btnBackHandler()">返回</button>
									</div> -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div region="south" style="height:40px;line-height:40px;text-align:center;overflow:hidden">
		<button class="btn"  type="button" onclick="toManager()" id="updateBtn">修改申请</button>
		<button class="btn"  type="button" onclick="btnBackHandler()">返回</button>
	</div>
</body>
</html>


